package ren.install.web.utils;

import ren.install.web.entity.ResultBean;
import ren.install.web.entity.ResultEnum;

/**
 * @author zhuyunhui
 * @date 2020-05-31 23:30
 */

public class ResultUtil<T> {

    public static <T> ResultBean<T> success(T t){
        ResultEnum successEnum = ResultEnum.SUCCESS;
        return new ResultBean<T>(successEnum.getCode(),successEnum.getMsg(),t);
    }

    public static <T> ResultBean<T> success(){
        return success(null);
    }

    public static <T> ResultBean<T> error(ResultEnum Enum){
        ResultBean<T> result = new ResultBean<T>();
        result.setCode(Enum.getCode());
        result.setMsg(Enum.getMsg());
        result.setData(null);
        return result;
    }
}
